{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-03-29T02:22:19.769598Z",
     "start_time": "2025-03-29T02:22:19.751599Z"
    }
   },
   "source": [
    "import torch\n",
    "import numpy as np"
   ],
   "outputs": [],
   "execution_count": 10
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-29T02:22:19.784598Z",
     "start_time": "2025-03-29T02:22:19.777598Z"
    }
   },
   "cell_type": "code",
   "source": [
    "x = torch.randn(2,3)\n",
    "x.shape\n",
    "print(x)\n",
    "print(x[:, 1])"
   ],
   "id": "7cccd2bfba1c6cbf",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 2.2151e-01, -1.0235e+00, -2.0476e-04],\n",
      "        [-8.8332e-01,  1.3976e+00,  6.1594e-01]])\n",
      "tensor([-1.0235,  1.3976])\n"
     ]
    }
   ],
   "execution_count": 11
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-29T02:22:19.879161Z",
     "start_time": "2025-03-29T02:22:19.861161Z"
    }
   },
   "cell_type": "code",
   "source": [
    "y = torch.randn(1,3)\n",
    "print(y)"
   ],
   "id": "e2a69fb8c590b2c6",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[ 1.3594, -1.1587,  0.9509]])\n"
     ]
    }
   ],
   "execution_count": 12
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-29T02:22:19.988404Z",
     "start_time": "2025-03-29T02:22:19.970406Z"
    }
   },
   "cell_type": "code",
   "source": [
    "z = torch.randn(3,1)\n",
    "print(z)"
   ],
   "id": "af518e1e04a7ba15",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[-0.0755],\n",
      "        [ 1.1947],\n",
      "        [ 0.7022]])\n"
     ]
    }
   ],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-29T02:36:47.712364Z",
     "start_time": "2025-03-29T02:36:47.706622Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a = np.array([[-2, 4]])\n",
    "w = np.array([[1, 2], [-3, 4], [5, -6]])\n",
    "print(a.shape)\n",
    "print(w.shape)\n",
    "print(w)\n",
    "print(w.T)\n",
    "print(np.dot(a, w.T))"
   ],
   "id": "473296ddd7860caa",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 2)\n",
      "(3, 2)\n",
      "[[ 1  2]\n",
      " [-3  4]\n",
      " [ 5 -6]]\n",
      "[[ 1 -3  5]\n",
      " [ 2  4 -6]]\n",
      "[[  6  22 -34]]\n"
     ]
    }
   ],
   "execution_count": 28
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-03-29T02:50:56.586480Z",
     "start_time": "2025-03-29T02:50:56.573481Z"
    }
   },
   "cell_type": "code",
   "source": [
    "zz = np.matmul(a, w.T)\n",
    "print(zz)\n",
    "print(a @ w.T)"
   ],
   "id": "b715b980676ccee7",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  6  22 -34]]\n",
      "[[  6  22 -34]]\n"
     ]
    }
   ],
   "execution_count": 31
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
